<?php
/**
 * Created by PhpStorm.
 * User: lullabies
 * Date: 2019/5/24
 * Time: 9:25
 */

namespace app\api\model;


use think\Model;

class Works extends Model
{
    /**
     * 通过科目id获取作品相关信息
     */
    public static function getInfoBySubject($subject_id,$page,$page_size){
        $result = self::where(['subject_id'=>$subject_id,'status' =>1])
            ->page($page,$page_size)
            ->field('id,img,user_id')
            ->order('create_time','desc')
            ->select();
        return $result;
    }
    /**
     * 通过科目和用户id 获取作品
     */
    public static function getInfoBySubjectUser($subject_id,$user_id){
        $result = self::where(['subject_id'=>$subject_id,'status' =>1,'user_id'=>$user_id])
            ->find();
        return $result;
    }
}